<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<?PHP
//echo phpinfo();
include("common/connect.php");
include("common/common.php");

echo "start<br>";

$result = mysql_query( "select * from return_record where trade_id <>'' and sumcheck=0 order by id" );
while( $result && $row = mysql_fetch_assoc( $result ))
{
	$tradeid = $row["trade_id"];
	echo "<br>".$tradeid."  ".$row["tb_id"];
//	exit;
	$tradeid_begin = substr($tradeid, 0, 6);
	$tradeid_end = substr($tradeid, -4);
	$result2 = mysql_query("select * from report_items where trade_id like '".$tradeid_begin."%".$tradeid_end."'");
	$count = mysql_num_rows($result2);
	if ($count > 0)
	{
		$row2 = mysql_fetch_assoc( $result2);
		echo "<br>--------".$row2["id"]." ".$row2["trade_id"]."  ----------";
		
		mysql_query( "update return_record set sumcheck=1 where id=".$row["id"] );
		if (mysql_affected_rows() == 0)
		{
			echo "<script>alert('处理过程中发生失败，请告诉程序员，出错代码：1');</script>";
			exit;
		}
	}
}

echo "<br>end";
?>


</body>
</html>